# Copyright (c) Huawei Technologies Co., Ltd. 2025. All rights reserved.
# This source file is part of the Cangjie project, licensed under Apache-2.0
# with Runtime Library Exception.
#
# See https://cangjie-lang.cn/pages/LICENSE for license information.


from os import path

prefixes = ['---', '++-', '-++', '+', '*', '**', '/']
warnings = ['+', '*', '**', '/']
path = path.dirname(path.realpath(__file__)) + '/test_a03_{}.cj'
template = '''
/*
 * Copyright (c) Huawei Technologies Co., Ltd. 2025. All rights reserved.
 * This source file is part of the Cangjie project, licensed under Apache-2.0
 * with Runtime Library Exception.
 *
 * See https://cangjie-lang.cn/pages/LICENSE for license information.
 */

/*
  @Assertion:   4.15(3)  The syntax of arithmetic expressions are defined as:
                prefixUnaryExpression
                    : prefixUnaryOperator* incAndDecExpression
                    ;
                prefixUnaryOperator
                    : '-'
                    | ...
                    ;
                additiveExpression
                    : multiplicativeExpression (additiveOperator multiplicativeExpression)*
                    ;
                multiplicativeExpression
                    : exponentExpression (multiplicativeOperator exponentExpression)*
                    ;
                exponentExpression
                    : prefixUnaryExpression (exponentOperator prefixUnaryExpression)*
                    ;
                additiveOperator
                    : '+' | '-'
                    ;
                multiplicativeOperator
                    : '*' | '/' | '%'
                    ;
                exponentOperator
                    : '**'
                    ;
  @Description: Checks that prefix {p} is not permitted.
  @Mode: compileonly
  @Negative: yes
  @Structure: single
  @CompileWarning: {}
  @Comment: Auto-generated by gen_prefix.py
*/

main() {{
    let expr = 1.0
    {p}expr
}}
'''

counter = 2
    
for p in prefixes:
  counter += 1
  with open(path.format(str(counter).zfill(2)), 'w') as file:
    file.write(template.format('yes' if p in warnings else 'no', p=p))
       